package com.sx.service.system;

import com.sx.basic.ResponseEntity;
import com.sx.basic.pageable.Condition;
import com.sx.basic.service.BasicService;
import com.sx.basic.service.impl.BasicServiceImpl;
import com.sx.dao.system.MenuRepository;
import com.sx.entity.system.MenuEntity;
import com.sx.service.system.IMenuService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author AdinZ
 * @date 2020/11/10 18:22
 */
@Service
public class MenuService extends BasicServiceImpl<MenuRepository, MenuEntity,Long>
        implements IMenuService, BasicService<MenuEntity, Long> {
    @Override
    public ResponseEntity<List<MenuEntity>> getList(String action) {
        return null;
    }

    @Override
    public List<MenuEntity> findMenu(MenuEntity.Action action) {
        List<MenuEntity> list=this.redisService.get(MenuEntity.KEY(action),0,99999999);
        if(list==null||list.size()==0) {
            list= this.findList(new Condition().eq("action", action));
            if(list!=null&&list.size()>0){
                this.redisService.set(MenuEntity.KEY(action),list);
            }
        }
        return list;
    }

}
